<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/base/BaseFormFilterPropel.class.php');

/**
 * CartItem filter form base class.
 *
 * @package    wifilez
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfPropelFormFilterGeneratedTemplate.php 16976 2009-04-04 12:47:44Z fabien $
 */
class BaseCartItemFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'cart_id'      => new sfWidgetFormPropelChoice(array('model' => 'Cart', 'add_empty' => true)),
      'product_id'   => new sfWidgetFormPropelChoice(array('model' => 'Product', 'add_empty' => true)),
      'quantity'     => new sfWidgetFormFilterInput(),
      'reserved'     => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'cart_id'      => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Cart', 'column' => 'cart_id')),
      'product_id'   => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Product', 'column' => 'product_id')),
      'quantity'     => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'reserved'     => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
    ));

    $this->widgetSchema->setNameFormat('cart_item_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'CartItem';
  }

  public function getFields()
  {
    return array(
      'cart_item_id' => 'Number',
      'cart_id'      => 'ForeignKey',
      'product_id'   => 'ForeignKey',
      'quantity'     => 'Number',
      'reserved'     => 'Number',
    );
  }
}
